/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Task2;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.rmi.Naming;

/**
 *
 * @author Patrick Füssinger
 * ITB5_2
 * Enterprise Applications
 * Exercise 1
 * bis 13.11.2011
 */

public class RmiClient {

    public static void main(String[] args) {
        //CalcStub ist eine Instanc von Stub und implentiert das Calc Interface
        //und ist zum RmiSquare RemoteObjekt gebunden
        iCalculate iCalcStub = null;

        try {
            System.out.println("IP-Adresse: ");
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            String sIPAdresse = in.readLine();
            System.out.println("Bitte Zahl eingeben: ");
            in = new BufferedReader(new InputStreamReader(System.in));
            int iNumber = Integer.parseInt(in.readLine());

            //Refernz zum RemoteObjekt holen
            iCalcStub = (iCalculate) Naming.lookup("rmi://" + sIPAdresse + "/RmiSquare");
            System.out.println("Quadrat von " + iNumber + " ist: " + iCalcStub.square(iNumber));

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
